home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / LaZaRuS XXIII.txt < prev    next >
Encoding:
Text File  |  1999-07-07  |  12.4 KB  |  254 lines

  1.  
  2.  
  3.                      L                ZZZZZZ         RRRRR           SSSSS
  4.                      L                    Z          R    R         S
  5.                      L          aaa      Z      aaa  R    R  u   u  S
  6.                      L            a     Z         a  RRRRR   u   u  SSSSS
  7.                XX    L         aaaa    Z       aaaa  R    R  u   u       S
  8.               XXXX   L        a   a   Z       a   a  R    R  u   u       S
  9.              XXXXXX  LLLLLLL  aaaaa  ZZZZZZZ  aaaaa  R    R  uuuuu  SSSSSS
  10.              XXXXXX       
  11.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  12.        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  13.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  14.              XXXXXX
  15.              XXXXXX
  16.               XXXX        proudly presents his 23.Cracking Tutorial (06.07.1999)
  17.                XX                    Cracking VB5 progs with W32Dasm
  18.  
  19. I.    Introduction
  20. II.   The essay
  21. III.  BTW
  22. IV.   All Tutorials by LaZaRuS
  23.  
  24. I.   Welcome to my 23st cracking tutorial.
  25.      Yep, I know: There's a handy little tool call Smartcheck. I tried to download it once, but
  26.      I got a corrupted RAR file. D/l it again? Nah, not with my "turtle"-connection. I already
  27.      have a disassembler and a debugger: W32Dasm and SICE. Actually there are some guys that
  28.      say the only thing you get for VB progs in W32Dasm is garbage. *Completely* wrong. It's
  29.      just a matter of interpretation. A VB5 prog in W32Dasm does (generally) look like a W32Asm 
  30.      prog without string references. The main difference is that VB progs are *easier* to crack.
  31.      It seems obvious that VB coders use the predefined functions for the comparison of the
  32.      good/bad serial. (and btw: razzia didn't have Smartcheck for his famous VB essay, too :P)
  33.      As examples I take two CrackMe's of BuLLeT (1.75 and 2.75).
  34.  
  35. I.1  W32Dasm 8.9
  36.      BuLLeT's CrackMe 1.75
  37.      BuLLeT's CrackMe 2.75
  38.      Audio List Maker 1.52.1016
  39.  
  40. II.  The essay
  41.      Let's start with the first CrackMe. When you disassemble it you will nothing but the 
  42.      functions that are called MSVBVM50.DLL.
  43.  
  44.      Import Module 001: MSVBVM50.DLL
  45.      Addr:0F0399BC hint(0000) Name: _CIcos
  46.      Addr:0F0E7F94 hint(0000) Name: _adj_fptan
  47.      Addr:0F0E7855 hint(0000) Name: _adj_fdiv_m64
  48.      Addr:0F0E7EDC hint(0000) Name: _adj_fprem1
  49.      Addr:0F02B4EB hint(0000) Name: __vbaHresultCheckObj
  50.      Addr:0F0E7809 hint(0000) Name: _adj_fdiv_m32
  51.      Addr:0F01E2F2 hint(0000) Name: __vbaObjSet
  52.      Addr:0F0E78A1 hint(0000) Name: _adj_fdiv_m16i
  53.      Addr:0F0E79A1 hint(0000) Name: _adj_fdivr_m16i
  54.      Addr:0F0399B2 hint(0000) Name: _CIsin
  55.      Addr:0F01F90B hint(0000) Name: __vbaChkstk
  56.      Addr:0F02299D hint(0000) Name: EVENT_SINK_AddRef
  57.      Addr:0F01F8F6 hint(0000) Name: __vbaStrCmp
  58.      Addr:0F0E7F91 hint(0000) Name: _adj_fpatan
  59.      Addr:0F037FD1 hint(0000) Name: EVENT_SINK_Release
  60.      Addr:0F0342BF hint(0000) Name: _CIsqrt
  61.      Addr:0F03634A hint(0000) Name: EVENT_SINK_QueryInterface
  62.      Addr:0F022B59 hint(0000) Name: __vbaExceptHandler
  63.      Addr:0F0E7C24 hint(0000) Name: _adj_fprem
  64.      Addr:0F0E7955 hint(0000) Name: _adj_fdivr_m64
  65.      Addr:0F10A1A4 hint(0000) Name: __vbaFPException
  66.      Addr:0F0342B5 hint(0000) Name: _CIlog
  67.      Addr:0F0E78D5 hint(0000) Name: _adj_fdiv_m32i
  68.      Addr:0F0E79D5 hint(0000) Name: _adj_fdivr_m32i
  69.      Addr:0F0E7909 hint(0000) Name: _adj_fdivr_m32
  70.      Addr:0F0E7344 hint(0000) Name: _adj_fdiv_r
  71.      Addr:0F00A1BF hint(0064) Name: ThunRTMain
  72.      Addr:0F0342AB hint(0000) Name: _CIatan
  73.      Addr:0F0EA765 hint(0000) Name: _allmul
  74.      Addr:0F0EA75B hint(0000) Name: _CItan
  75.      Addr:0F01F2DD hint(0000) Name: _CIexp
  76.      Addr:0F01F878 hint(0000) Name: __vbaFreeStr
  77.      Addr:0F01DC7F hint(0000) Name: __vbaFreeObj
  78.  
  79.      Some of the names are selfexplaining, some of them are cryptic, but some of them have an
  80.      interesting name: At least __vbaStrCmp - Doesn't it sound like StringCompare?
  81.      Let's search for appearances in the deadlisting. The first one is obviously not the one
  82.      that compares the good serial with the one you entered (Look at it and you'll see). The
  83.      second (and last) one looks more interesting.
  84.  
  85.      * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  86.      |:004106D3(C)
  87.      |
  88.      :004106E6 FF75E8                  push [ebp-18]
  89.      :004106E9 6850014100              push 00410150
  90.  
  91.      * Reference To: MSVBVM50.__vbaStrCmp, Ord:0000h
  92.                                        |
  93.      :004106EE E8C509FFFF              Call 004010B8
  94.      :004106F3 8BD8                    mov ebx, eax
  95.      :004106F5 8D4DE8                  lea ecx, dword ptr [ebp-18]
  96.      :004106F8 F7DB                    neg ebx
  97.      :004106FA 1BDB                    sbb ebx, ebx
  98.      :004106FC 43                      inc ebx
  99.      :004106FD F7DB                    neg ebx
  100.  
  101.      Enter the debug mode of W32Dasm and set a breakpoint on :004106E9. Then trace into the
  102.      next call. Tracing little further, you'll come to this:
  103.  
  104.      __vbaStrCmp()
  105.         :0F01F8F6 push [esp+08]
  106.         :0F01F8FA push [esp+08]
  107.         :0F01F8FE push 00000000
  108.         :0F01F900 call MSVBVM50.__vbaStrComp
  109.         :0F01F905 movsx eax, ax
  110.         :0F01F908 ret 0008
  111.  
  112.      MSVBVM50.__vbaStrComp? It's getting interesting, isn't it? Trace into this one, too.
  113.  
  114.      __vbaStrComp()
  115.         :0F003563 push ebp
  116.         :0F003564 mov ebp, esp
  117.         :0F003566 push ebx
  118.         :0F003567 push esi
  119.         :0F003568 push edi
  120.         :0F003569 cmp dword ptr [ebp+10], 00000000 // [ebp+10] points to the first string
  121.         :0F00356D mov esi, 00000000
  122.         :0F003572 je 0F00357A // if first string = "", then jump
  123.         :0F003574 mov eax, dword ptr [ebp+10]  //Here is the first string that is compared
  124.         :0F003577 mov esi, dword ptr [eax-04]  //ESI = Length(first string)*2
  125.         :0F00357A cmp dword ptr [ebp+0C], 00000000 //[ebp+0C] points to the second string
  126.         :0F00357E mov edi, 00000000
  127.         :0F003583 je 0F00358B
  128.         :0F003585 mov ecx, dword ptr [ebp+0C] // ECX = second string that is compared
  129.         :0F003588 mov edi, dword ptr [ecx-04] // EDI = Length(second string)*2
  130.         :0F00358B cmp edi, esi // compare stringlength of both strings
  131.         :0F00358D mov ebx, edi // save lenght of second string in EBX
  132.         :0F00358F jnb 0F0035B6 // if string two has less chars, then string one, then jump
  133.         :0F003591 cmp dword ptr [ebp+08], 00000000
  134.         :0F003595 jne 0F0035CD
  135.         :0F003597 test ebx, ebx
  136.         :0F003599 je 0F0035C3
  137.         :0F00359B mov eax, ebx
  138.         :0F00359D shr eax, 1
  139.         :0F00359F push eax
  140.         :0F0035A0 push [ebp+0C] // points to second string
  141.         :0F0035A3 push [ebp+10] // points to first string
  142.         :0F0035A6 call MSVBVM50.0F00D9EA // this one compares them "really" and sets flag
  143.         :0F0035AB test eax, eax // if they are the same
  144.         :0F0035AD je 0F0035BA // then jump
  145.         :0F0035AF pop edi // else return from call with "Not same" flag
  146.         :0F0035B0 pop esi
  147.         :0F0035B1 pop ebx
  148.         :0F0035B2 pop ebp
  149.         :0F0035B3 ret 000C
  150.         :0F0035B6 mov ebx, esi
  151.         :0F0035B8 jmp MSVBVM50.0F003591
  152.  
  153.      Here is the call at :F0035A6 that compares the two strings really.
  154.  
  155.         :0F00D9EA push esi // save esi
  156.         :0F00D9EB push edi // save edi
  157.         :0F00D9EC mov edi, dword ptr [esp+10] // edi = first string
  158.         :0F00D9F0 mov esi, dword ptr [esp+0C] // esi = second string
  159.         :0F00D9F4 mov ecx, dword ptr [esp+14] // ecx = length of both strings
  160.         :0F00D9F8 xor eax, eax // erase eax
  161.         :0F00D9FA repz // this one
  162.         :0F00D9FB cmpsw // compares them
  163.         :0F00D9FD je 0F00DA04 // if they are equal, then jump
  164.         :0F00D9FF sbb eax, eax // else
  165.         :0F00DA01 sbb eax, FFFFFFFF // set "not equal" flag
  166.         :0F00DA04 pop edi // restore edi
  167.         :0F00DA05 pop esi // restore esi
  168.         :0F00DA06 ret 000C // return from call
  169.  
  170.      What do I want to show you? Just that every standard comparison of two strings must pass
  171.      this lines of code. So breakpointing with SICE at :0F00D9F4 would easily reveal which 
  172.      strings are compared.
  173.  
  174.      Another example: BuLLeT's CrackMe 2.75:
  175.      In this CrackMe we have no __vbaStrCmp :( - The important call is __vbaVarTstEq. The second
  176.      appearance is the correct here, too. After some tracing (enter every callyou come - Yeah 
  177.      guess where you come. You will come to __vbaStrComp() again and then to the passage 
  178.      described above where the two strings are compared. 
  179.  
  180.      :0F00D9EC mov edi, dword ptr [esp+10] // edi = real serial
  181.      :0F00D9F0 mov esi, dword ptr [esp+0C] // esi = serial, you entered
  182.  
  183.      Just as I said: No matter which method of comparison is used by the programmer, this part
  184.      of code will always be executed. One string will always be in esi, the other one will always
  185.      be in edi.
  186.  
  187.      btw: I nearly forgot
  188.      The serial for the first CrackMe is 2hard4u2crackm8
  189.      The serial for the second CrackMe is 2rK4HJ4-7n8RgT09IW6a7kSlg33
  190.  
  191.      Attention: Remember that strings in VB are stored in "Wide char" format like this:
  192.  
  193.      [edi+00000000] - 00720032  2.r.
  194.      [edi+00000004] - 0034004b  K.4.
  195.      [edi+00000008] - 004a0048  H.J.
  196.      [edi+0000000C] - 002d0034  4.-.
  197.      [edi+00000010] - 006e0037  7.n.
  198.      [edi+00000014] - 00520038  8.R.
  199.      [edi+00000018] - 00540067  g.T.
  200.      [edi+0000001C] - 00390030  0.9.
  201.      [edi+00000020] - 00570049  I.W.
  202.      [edi+00000024] - 00610036  6.a.
  203.      [edi+00000028] - 006b0037  7.k.
  204.      [edi+0000002C] - 006c0053  S.l.
  205.      [edi+00000030] - 00330067  g.3.
  206.      [edi+00000034] - 00000033  3...
  207.  
  208.      Just get rid of every 00h and you will get the serial.
  209.      Farthermore the wide char format is the reason, that not the "real" length of the strings 
  210.      is compared, but length*2.
  211.  
  212.  
  213.      Eh, do I still hear doubts in your voice? Just CrackMes? Small deadlisting? I had luck?
  214.      May a crack for a "real" program convince you? OK, here it comes. The target is Audio 
  215.      List Maker 1.52.1016. The EXE file is 355 KB big, the deadlisting is 6445KB. I hope that 
  216.      satisfies you. There are quite many __vbaStrCmp in the listing, but that shouldn't frighten
  217.      us. With some *zen* we can easily eliminate most. When you enter a wrong serial, a 
  218.      messagebox appears. I believe that there's a messagebox when you enter a correct serial,
  219.      too. Now it's only speculation, but we will later see, that it is indeed so. So look at
  220.      the __vbaStrCmp calls and you will soon find this one:
  221.  
  222.      :0044877B 8B55E4                  mov edx, dword ptr [ebp-1C] ;; point to real serial
  223.      :0044877E 8B45D8                  mov eax, dword ptr [ebp-28] ;; point to entered serial
  224.      :00448781 52                      push edx ;; save real serial to stack
  225.      :00448782 50                      push eax ;; save entered serial to stack
  226.  
  227.      * Reference To: MSVBVM50.__vbaStrCmp, Ord:0000h
  228.                                        |
  229.      :00448783 FF1540824500            Call dword ptr [00458240] ;; compare them and set flag
  230.      :00448789 85C0                    test eax, eax ;; test flag
  231.      :0044878B 0F85B6050000            jne 00448D47 ;; if not set, then jump to "beggar off"
  232.  
  233.      I strongly believed that this one is "our" __vbaStrCmp, as there is a conditioned jump right
  234.      after the call that jumps to a MessageBox (MSVBVM50.rtcMsgBox). If the jump is not taken,
  235.      a messagebox will appear, too. Read the real serial out at :0044877B. For LaZaRuS it is
  236.      ALM4-3111-7951-9X2K where the "-" mustn't be entered in the program as there are only 16
  237.      chars allowed.
  238.  
  239.      Alright, I know what you are saying. When the serials are pushed in front of the __vbaStrCmp
  240.      why did we trace into the call in the two CrackMes??? Imagine that there are some ways
  241.      to hide the __vbaStrCmp in the deadlisting (for example: call edi - the indirect call 
  242.      through a register). In a deadlisting there won't be much chances to find that, but if you
  243.      put a breakpoint on the correct place inside the __vbaStrComp() function you can easily find
  244.      the addresses that call the __vbaStrCmp with the help of SICE.
  245.  
  246.  
  247. III. BTW
  248.      
  249.      Greets to: tKC, Ed!son, Moral Insanity, +Sandman, Fravia+ and everyone at #cracking4newbies,
  250.      +Sandman's forum and Fravia+'s forum.
  251.  
  252. IV.  All tutorials by LaZaRuS
  253.       
  254.